package com.bfsuol.yihang.cars.service;

import com.bfsuol.yihang.cars.api.CommandVehicleService;
import com.bfsuol.yihang.cars.domain.VehicleService;
import com.bfsuol.yihang.cars.dto.VehicleDTO;
import com.bfsuol.yihang.cars.entity.VehicleEntity;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CommandVehicleServiceImpl implements CommandVehicleService {

    @Autowired
    private VehicleService vehicleService;

    @Override
    public void save(VehicleDTO vehicleDTO) {
        VehicleEntity  vehicleEntity = new VehicleEntity();
        BeanUtils.copyProperties(vehicleDTO,vehicleEntity);
        vehicleService.save(vehicleEntity);
    }

    @Override
    public void updateById(VehicleDTO vehicleDTO) {
        VehicleEntity  vehicleEntity = new VehicleEntity();
        BeanUtils.copyProperties(vehicleDTO,vehicleEntity);
        vehicleService.updateById(vehicleEntity);
    }

    @Override
    public void deleteById(Long id) {
        vehicleService.removeById(id);
    }
}
